<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        {{count}}
        <button @click="add">add</button>
        <br>
        {{obj}}
    </div>
    <script src="./js/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                count: 0,
                obj: {
                    name: 'bob',
                    age: 10
                }
            },
            methods: {
                add() {
                    this.count++
                }
            },
            watch: {
                count(newValue, oldValue) {
                    console.log('newValue', newValue)
                    console.log('oldValue', oldValue)
                    // this.count++
                },
                obj(newValue, oldValue) {
                    console.log('newValue', newValue)
                    console.log('oldValue', oldValue)
                    this.obj = {
                        name: 'rose',
                        age: this.obj.age++
                    }
                },
                'obj.name': {
                    handler() {
                        console.log('newValue', newValue)
                    },
                    deep: true
                }
            }
        })
    </script>
</body>

</html>